/*
    Taken from SDL_net, and modified for Kizare
*/
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define CNetwork_Pack_Header(tData, Part, MaxParts, Arg1) 	\
do					\
{					\
	Uint8* Data = (Uint8 *)(tData);	\
	Data[1] = (Part >> 24) & 0xFF;	\
	Data[2] = (Part >> 16) & 0xFF;	\
	Data[3] = (Part >>  8) & 0xFF;	\
	Data[4] =  Part       & 0xFF;	\
	\
	Data[5] = (MaxParts >> 24) & 0xFF;	\
	Data[6] = (MaxParts >> 16) & 0xFF;	\
	Data[7] = (MaxParts >>  8) & 0xFF;	\
	Data[8] =  MaxParts       & 0xFF;	\
	\
	Data[9] = (Size >> 24) & 0xFF;	\
	Data[10] = (Size >> 16) & 0xFF;	\
	Data[11] = (Size >>  8) & 0xFF;	\
	Data[12] =  Size       & 0xFF;	\
	\
	Data[13] = (Arg1 >> 24) & 0xFF;	\
	Data[14] = (Arg1 >> 16) & 0xFF;	\
	Data[15] = (Arg1 >>  8) & 0xFF;	\
	Data[16] =  Arg1       & 0xFF;	\
} while ( 0 )
#else
#define CNetwork_Pack_Header(tData, Part, MaxParts, Size, Arg1) 	\
do					\
{					\
	Uint8* Data = (Uint8 *)(tData);	\
	Data[4] = (Part >> 24) & 0xFF;	\
	Data[3] = (Part >> 16) & 0xFF;	\
	Data[2] = (Part >>  8) & 0xFF;	\
	Data[1] =  Part       & 0xFF;	\
	\
	Data[8] = (MaxParts >> 24) & 0xFF;	\
	Data[7] = (MaxParts >> 16) & 0xFF;	\
	Data[6] = (MaxParts >>  8) & 0xFF;	\
	Data[5] =  MaxParts       & 0xFF;	\
	\
	Data[12] = (Size >> 24) & 0xFF;	\
	Data[11] = (Size >> 16) & 0xFF;	\
	Data[10] = (Size >>  8) & 0xFF;	\
	Data[9] =  Size       & 0xFF;	\
	\
	Data[16] = (Arg1 >> 24) & 0xFF;	\
	Data[15] = (Arg1 >> 16) & 0xFF;	\
	Data[14] = (Arg1 >>  8) & 0xFF;	\
	Data[13] =  Arg1       & 0xFF;   \
} while ( 0 )
#endif


#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define CNetwork_Unpack_Header(tData, Part, MaxParts, Size, Arg1) 		\
do					\
{					\
	Uint8* Data = (Uint8 *)(tData);	\
	\
	Part = ((((Uint8 *)Data)[1] << 24) | (((Uint8 *)Data)[2] << 16) | \
	 (((Uint8 *)Data)[3] <<  8) |  ((Uint8 *)Data)[4] <<  0);\
    MaxParts = ((((Uint8 *)Data)[5] << 24) | (((Uint8 *)Data)[6] << 16) | \
	 (((Uint8 *)Data)[7] <<  8) |  ((Uint8 *)Data)[8] <<  0);\
    Size = ((((Uint8 *)Data)[9] << 24) | (((Uint8 *)Data)[10] << 16) | \
	 (((Uint8 *)Data)[11] <<  8) |  ((Uint8 *)Data)[12] <<  0);\
} while ( 0 )
#else
    #define CNetwork_Unpack_Header(Data, Part, MaxParts, Size, Arg1) 		\
	Part = ((((Uint8 *)Data)[4] << 24) | (((Uint8 *)Data)[3] << 16) | \
	 (((Uint8 *)Data)[2] <<  8) |  ((Uint8 *)Data)[1] <<  0);\
    MaxParts = ((((Uint8 *)Data)[8] << 24) | (((Uint8 *)Data)[7] << 16) | \
	 (((Uint8 *)Data)[6] <<  8) |  ((Uint8 *)Data)[5] <<  0);\
    Size = ((((Uint8 *)Data)[12] << 24) | (((Uint8 *)Data)[11] << 16) | \
	 (((Uint8 *)Data)[10] <<  8) |  ((Uint8 *)Data)[9] <<  0);\
	Arg1 = ((((Uint8 *)Data)[16] << 24) | (((Uint8 *)Data)[15] << 16) | \
	 (((Uint8 *)Data)[14] <<  8) |  ((Uint8 *)Data)[13] <<  0);
#endif
